// 该文件专门用于创建整个应用的路由器
import VueRouter from "vue-router";

// 引入组件
import Page from '@/pages/Page'
import Goods from '@/pages/Goods'
import Undeveloped from '@/pages/Undeveloped'
import User from '@/pages/User'
import Release from '@/pages/Release'
import Lookmydetailed from '@/pages/Lookmydetailed'
import Updatamydetailed from '@/pages/Updatamydetailed'
import Reservation from '@/pages/Reservation'

// 引入vue
import Vue from 'vue';
// 应用插件
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}



// 创建并暴露一个路由器
export default new VueRouter({
    mode: 'history',
    base: '/',
    routes: [
        {
            name: 'Page',
            path: '/management/page',
            component: Page,
        },
        {
            name: 'Goods',
            path: '/management/goods',
            component: Goods,
            children: [
                {
                    name: 'Lookmydetailed',
                    path: 'lookmydetailed',  // 子路径可以不加/【父子组件可以同时存在】
                    component: Lookmydetailed,
                },
                {
                    name: 'Updatamydetailed',
                    path: 'updatamydetailed',
                    component: Updatamydetailed,
                },
            ]
        },
        {
            name: 'User',
            path: '/management/user',
            component: User,
        },
        {
            name: 'Reservation',
            path: '/management/reservation',
            component: Reservation,
            children: [
                {
                    name: 'Lookreservation',
                    path: 'lookreservation',  // 子路径可以不加/【父子组件可以同时存在】
                    component: Lookmydetailed,
                },
            ]
        },
        {
            name: 'Undeveloped',
            path: '/management/undeveloped',
            component: Undeveloped,
        },

        {
            name: 'Release',
            path: '/release',
            component: Release,
        },


    ]
})

